<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('功能关系配置新增及修改')" />
    <style type="text/css">
        .layui-input, .layui-textarea{width:calc(100% - 100px);}
        .layui-form-label{width:180px}
        .layui-form-select dl{margin-left:80px;min-width: calc(100% - 100px);}
        .layui-edge{margin-right:28px;}
    </style>
</head>
<body>
<form class="layui-form" id="form-relation-add" style="padding: 16px 84px 16px 25px;">
<input type="hidden" id="guid" name="guid"  th:value="${dictionaryRelationForModule?.guid}">
<div class="">
	<div class="layui-form-item">
	  <label class="layui-form-label">调入关系名称：</label>
	  <div class="layui-input-block">
	    <input type="text" name="relationName" id="relationName" th:value="${dictionaryRelationForModule?.relationName}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
	  </div>
	</div>
	<div class="layui-form-item">
	  <label class="layui-form-label">源数据地址：</label>
	  <div class="layui-input-block">
	    <input type="text" name="sourceDataurl" id="sourceDataurl" th:value="${dictionaryRelationForModule?.sourceDataurl}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
	  </div>
	</div>
	<div class="layui-form-item">
	  <label class="layui-form-label">源功能唯一标识(取实体)：</label>
	  <div class="layui-input-block">
	    <input type="text" name="sModuleTable" id="sModuleTable" th:value="${dictionaryRelationForModule?.sModuleTable}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
	  </div>
	</div>
	<div class="layui-form-item">
	  <label class="layui-form-label">源数据字段标识(取列名)：</label>
	  <div class="layui-input-block">
	    <input type="text" name="sModuleTableField" id="sModuleTableField" th:value="${dictionaryRelationForModule?.sModuleTableField}" autocomplete="off" placeholder="请输入" class="layui-input">
	  </div>
	</div>
	<div class="layui-form-item">
	  <label class="layui-form-label">目标功能唯一标识：</label>
	  <div class="layui-input-block">
	    <input type="text" name="rModuleTable" id="rModuleTable" th:value="${dictionaryRelationForModule?.rModuleTable}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
	  </div>
	</div>
	<div class="layui-form-item">
	  <label class="layui-form-label">排序：</label>
	  <div class="layui-input-block">
	    <input type="text" name="relationOrder" id="relationOrder" th:value="${dictionaryRelationForModule?.relationOrder}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
	  </div>
	</div>
	<div class="layui-form-item">
	  <label class="layui-form-label">功能状态：</label>
	  <div class="layui-input-block">
	    <input type="radio" name="bdeleted" value="0" title="启用" checked>
	    <input type="radio" name="bdeleted" value="1" title="停用" th:checked="${dictionaryRelationForModule?.bdeleted}? true : false">
	  </div>
	</div>
    <div class="layui-form-item">
        <label class="layui-form-label">调入SQL条件：</label>
        <div class="layui-input-block">
        	<textarea id="relationWhereStr" name="relationWhereStr" class="layui-textarea" placeholder="请输入内容" th:text="${dictionaryRelationForModule?.relationWhereStr}"></textarea>
        </div>
    </div>
</div>
<div class="layui-form-item layui-hide">
	<input type="button" lay-submit="" lay-filter="btn_save" id="btn_save" value="保存">
</div>
</form>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = ctx + "system/dictionaryrelationformodule";
	var dictionaryRelationForModule=[[${dictionaryRelationForModule}]];
	/*]]>*/
</script>
<script type="text/javascript">
var $,layer,form,table;
layui.use(['table','form','layer','jquery'], function () {
    $ = layui.$,layer = layui.layer,form = layui.form,table = layui.table;
    if(!dictionaryRelationForModule)$("#rModuleTable").val(window.location.href.split("=")[1]);
});
$('#sModuleTable').on('click', function () {
	$.modal.open("功能选择", "/system/dictionaryformodule/select", 650, 510, function(index){
        var res = window["layui-layer-iframe" + index].callbackdata();
        console.log(res);
        if(res=="none"){
        	layer.msg("请选择！");
        }else{
            $("#sModuleTable").val(res.moduleTable);
            layer.close(index);
        } 
    });
});
$('#rModuleTable').on('click', function () {
	$.modal.open("功能选择", "/system/dictionaryformodule/select", 650, 510, function(index){
        var res = window["layui-layer-iframe" + index].callbackdata();
        if(res=="none"){
        	layer.msg("请选择！");
        }else{
            $("#rModuleTable").val(res.moduleTable);
            layer.close(index); 
        }
    });
});
//提交调用的方法
function submitHandler() {
	if($('#guid').val()){//通过判断guid是否存在来判断是新增还是保存
		if ($.validate.form()) {
            $.operate.save(prefix + "/editpost", {'dictionaryRelationForModuleItems':JSON.stringify([$.common.formToJSON('form-relation-add')])});
        }
	}else{
		if ($.validate.form()) {
			$.operate.save(prefix + "/addpost", {'dictionaryRelationForModuleItems':JSON.stringify([$.common.formToJSON('form-relation-add')])});
		}
	}
}
</script>
</body>
</html>
